﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    using DAL.Entities;

    public class DangNhapDAL : BaseDAL, UTL.IBaseDAL
    {
        public int Count()
        {
            throw new NotImplementedException();
        }

        public DataTable Select()
        {
            throw new NotImplementedException();
        }

        public DataTable Select(object obj)
        {
            throw new NotImplementedException();
        }

        public object GetByKey(object key)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id)
        {
            throw new NotImplementedException();
        }

        public bool Insert(object obj)
        {
            throw new NotImplementedException();
        }

        public bool Update(object obj)
        {
            throw new NotImplementedException();
        }

        public DataTable Search(string name)
        {
            throw new NotImplementedException();
        }

        public Boolean kiemtra_dangnhap(object obj)
        {
            var o = (Dang_Nhap)obj;
            string sql = @"select * from taikhoan where taikhoan='{0}' COLLATE SQL_Latin1_General_CP1_CS_AS and matkhau='{1}' COLLATE SQL_Latin1_General_CP1_CS_AS";
            sql = string.Format(sql,o.taikhoan,o.matkhau);
            DataTable dt = ExecuteQuery(sql);
            if (dt.Rows.Count > 0)
                return true;
            else
                return false;
        }
        public DataTable select_nhanvien(object obj)
        {
            var o = (Dang_Nhap)obj;
            string sql = @"select distinct b.Ma_NV as id,b.Ten_NV as ten from TaiKhoan a join NHANVIEN b on a.Ma_NV=b.Ma_NV where taikhoan='{0}' COLLATE SQL_Latin1_General_CP1_CS_AS";
            sql = string.Format(sql, o.taikhoan);
            return ExecuteQuery(sql);
        }

    }
}
